package com.iot08.common.config.mongodb.converter;

import com.iot08.common.utils.DateUtil;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;

import java.util.Date;

/**
 * @version 1.0
 * @Description: mongodb 查询时Date的处理
 * @time: 2020/9/25 17:57
 * @author: Rock
 */
@ReadingConverter
public class MongoDateReadingHandle implements Converter<Object, Date> {


    @Override
    public Date convert(Object source) {
        if (source instanceof Date) {
            DateUtil.hanldeMongoDate((Date) source, 2);
            return (Date) source;
        }
        return null;
    }
}
